package 字符串;

/**
 * @author ssh
 * @date 2025/8/31
 * @description 翻转字符串，输入是char数组
 */
public class 反转字符串 {
    public void reverseString(char[] s) {
        int l=0;
        int r=s.length-1;
        while (l<r){
            char temp = s[l];
            s[l]=s[r];
            s[r]=temp;
            l++;
            r--;
        }
    }

    public static void main(String[] args) {
        // 测试代码
        char[] s = {'h', 'e', 'l', 'l', 'o'};
        反转字符串 solution = new 反转字符串();
        solution.reverseString(s);
        System.out.println(s); // 输出: "olleh"
    }
}
